function t(t, e, a) {
    return e in t ? Object.defineProperty(t, e, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = a, t;
}

var e;

Page({
    data: (e = {
        order: {},
        cancelRefund: !1,
        addressId: "0",
        notRefund: !1,
        isRefund: !1,
        openAddress: !1,
        isReason: !1,
        active: null,
        show: !1,
        start: [],
        end: [],
        search: !1,
        keyword: "",
        list: [],
        candidate: [],
        date_start: "",
        date_end: "",
        time: 0,
        inSearch: !1,
        page_loading: !0,
        address: [],
        today: "",
        yesterday: "",
        weekday: "",
        chooseTime: !1
    }, t(e, "isRefund", !1), t(e, "noRefund", !1), t(e, "cancelOrder", !1), t(e, "detail", {}), 
    t(e, "changePrice", !1), t(e, "callPhone", !1), t(e, "custom", !1), t(e, "mobile", ""), 
    t(e, "isSend", !1), t(e, "sendType", 0), t(e, "price", 0), t(e, "express", 0), t(e, "total", 0), 
    t(e, "about", ""), t(e, "reset_time", 0), t(e, "dd", 0), t(e, "hh", 0), t(e, "mm", 0), 
    t(e, "status", 1), t(e, "iphone_x", !1), e),
    onLoad: function(t) {
        getApp().device().indexOf("iphone_x") > -1 && this.setData({
            iphone_x: !0
        }), this.setData({
            id: t.id,
            status: t.status
        }), this.getAddress();
    },
    getAddress: function() {
        var t = this;
        getApp().request({
            url: getApp().apiUrl.app_admin.refund_address
        }).then(function(e) {
            t.setData({
                address: e.data.data.list
            });
        });
    },
    look: function(t) {
        var e = t.currentTarget.dataset.src;
        getApp().api.previewImage({
            current: e,
            urls: [ e ]
        });
    },
    agree: function() {
        var t = this;
        getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.refund_handle,
            data: {
                order_refund_id: t.data.detail.id,
                type: t.data.detail.type,
                is_agree: 1,
                refund_price: t.data.detail.refund_price,
                merchant_remark: t.data.about
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), t.setData({
                list: [],
                notRefund: !1,
                openAddress: !1,
                isRefund: !1,
                addressId: 0
            }), t.getList()) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        });
    },
    getTime: function() {
        var t = this.data.reset_time - 1, e = 0, a = parseInt(t / 3600);
        t > 86400 && (e = parseInt(t / 86400), a = parseInt((t - 86400 * e) / 3600));
        var i = t % 3600, n = parseInt(i / 60);
        a < 10 && (a = "0" + a.toString()), n < 10 && (n = "0" + n.toString()), this.setData({
            reset_time: t,
            dd: e,
            hh: a,
            mm: n
        });
    },
    toSendType: function() {
        var t = this;
        1 == this.data.sendType ? 2 == this.data.status ? (getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.refund_handle,
            data: {
                is_express: 0,
                merchant_remark: "",
                type: this.data.detail.type,
                is_agree: 1,
                order_refund_id: this.data.detail.id
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), t.setData({
                list: [],
                isSend: !1,
                sendType: 0
            }), t.getList()) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        })) : (getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.send,
            data: {
                is_express: 0,
                words: "",
                order_id: this.data.detail.id
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), t.setData({
                list: [],
                isSend: !1,
                sendType: 0
            }), t.getList()) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        })) : (this.setData({
            isSend: !1
        }), 2 == this.data.status ? getApp().api.navigateTo({
            url: "/pages/app_admin/send/send?order_refund_id=" + this.data.detail.id
        }) : getApp().api.navigateTo({
            url: "/pages/app_admin/send/send?id=" + this.data.detail.id
        }));
    },
    copy: function() {
        getApp().api.setClipboardData({
            data: this.data.order.address,
            success: function(t) {
                getApp().api.getClipboardData({
                    success: function(t) {
                        console.log(t.data);
                    }
                });
            }
        });
    },
    getList: function() {
        var t = this;
        getApp().iView.$Toast({
            content: "加载中",
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.detail,
            data: {
                order_id: t.data.id
            },
            method: "post"
        }).then(function(e) {
            if (getApp().iView.$Toast.hide(), 0 == e.data.code) {
                var a = e.data.data.order;
                a.address = a.address.replace(/\s*/g, "");
                var i = 0;
                a.auto_cancel > 0 ? i = a.auto_cancel : a.auto_confirm > 0 ? i = a.auto_confirm : a.auto_sales > 0 && (i = a.auto_sales), 
                a.refund_info.id > 0 && (a.refund_info.pic_list = JSON.parse(a.refund_info.pic_list), 
                t.setData({
                    detail: a.refund_info
                })), t.setData({
                    order: a,
                    reset_time: i
                }), setInterval(function() {
                    t.getTime();
                }, 1e3);
            } else getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        });
    },
    toCall: function(t) {
        var e = t.currentTarget.dataset.mobile;
        this.setData({
            callPhone: !this.data.callPhone,
            mobile: e
        });
    },
    decline: function(t) {
        var e = t.currentTarget.dataset.type, a = this;
        if (this.data.cancelRefund && (e = 2), 1 == e && a.data.addressId < 1) return getApp().iView.$Toast({
            content: "请选择地址",
            duration: 2,
            type: "warning"
        }), !1;
        getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.refund_handle,
            data: {
                order_refund_id: a.data.detail.id,
                type: a.data.detail.type,
                is_agree: e,
                address_id: a.data.addressId,
                refund_price: a.data.detail.refund_price,
                merchant_remark: a.data.about
            },
            method: "post"
        }).then(function(t) {
            getApp().iView.$Toast.hide(), 0 == t.data.code ? (getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), a.setData({
                list: [],
                notRefund: !1,
                cancelOrder: !1,
                openAddress: !1,
                addressId: 0
            }), a.getList()) : getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        });
    },
    call: function() {
        getApp().api.makePhoneCall({
            phoneNumber: this.data.mobile
        }), this.setData({
            callPhone: !this.data.callPhone
        });
    },
    toRefund: function(t) {
        var e = t.currentTarget.dataset.detail;
        this.setData({
            isRefund: !this.data.isRefund,
            detail: e
        });
    },
    chooseSend: function(t) {
        var e = this, a = t.currentTarget.dataset.send;
        e.setData({
            sendType: a
        });
    },
    cancel: function() {
        this.setData({
            date_start: "",
            date_end: "",
            isRefund: !1,
            chooseTime: !1,
            noRefund: !1,
            changePrice: !1,
            cancelOrder: !1,
            callPhone: !1,
            isSend: !1,
            notRefund: !1,
            openAddress: !1,
            isReason: !1,
            addressId: 0
        });
    },
    noCancel: function() {
        var t = this;
        getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), getApp().request({
            url: getApp().apiUrl.app_admin.cancel,
            data: {
                status: 2,
                remark: this.data.about,
                order_id: t.data.detail.id
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), t.setData({
                list: [],
                noRefund: !1
            }), t.getList()) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        });
    },
    cancelSubmit: function() {
        var t = this;
        getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), t.data.price > -.01 && t.data.express > -.01 ? getApp().request({
            url: getApp().apiUrl.app_admin.cancel,
            data: {
                status: 1,
                remark: "",
                order_id: t.data.detail.id
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), t.setData({
                list: [],
                cancelOrder: !1
            }), t.getList()) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        }) : t.data.price && "number" == typeof t.data.price ? t.data.express && "number" == typeof t.data.express || getApp().iView.$Toast({
            content: "运费必须大于等于0",
            duration: 2,
            type: "warning"
        }) : getApp().iView.$Toast({
            content: "商品总价必须大于等于0",
            duration: 2,
            type: "warning"
        });
    },
    lookAbout: function(t) {
        var e = t.currentTarget.dataset.detail;
        this.setData({
            detail: e,
            isReason: !0
        });
    },
    chooseAddress: function(t) {
        var e = t.currentTarget.dataset.address;
        e == this.data.addressId && (e = ""), this.setData({
            addressId: e
        });
    },
    refundHandle: function(t) {
        var e = t.currentTarget.dataset.type, a = t.currentTarget.dataset.detail;
        1 == t.currentTarget.dataset.cancel && this.setData({
            cancelRefund: !0
        }), 1 == e ? this.setData({
            detail: a,
            openAddress: !0
        }) : 2 == e && this.setData({
            detail: a,
            notRefund: !0
        });
    },
    beNotRefund: function(t) {
        var e = t.currentTarget.dataset.detail;
        this.setData({
            noRefund: !this.data.noRefund,
            detail: e
        });
    },
    toCancelorder: function(t) {
        var e = t.currentTarget.dataset.detail;
        this.setData({
            cancelOrder: !this.data.cancelOrder,
            detail: e
        });
    },
    submitChange: function() {
        var t = this;
        getApp().iView.$Toast({
            type: "loading",
            duration: 0
        }), t.data.price > -.01 && t.data.express > -.01 ? getApp().request({
            url: getApp().apiUrl.app_admin.update_price,
            data: {
                order_id: t.data.detail.id,
                total_price: t.data.price,
                express_price: t.data.express
            },
            method: "post"
        }).then(function(e) {
            getApp().iView.$Toast.hide(), 0 == e.data.code ? (getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "success",
                mask: !1
            }), t.setData({
                list: [],
                changePrice: !1
            }), t.getList()) : getApp().iView.$Toast({
                content: e.data.msg,
                duration: 2,
                type: "warning"
            });
        }).catch(function(t) {
            getApp().iView.$Toast({
                content: t.data.msg,
                duration: 2,
                type: "error"
            });
        }) : t.data.price && "number" == typeof t.data.price ? t.data.express && "number" == typeof t.data.express || getApp().iView.$Toast({
            content: "运费必须大于等于0",
            duration: 2,
            type: "warning"
        }) : getApp().iView.$Toast({
            content: "商品总价必须大于等于0",
            duration: 2,
            type: "warning"
        });
    },
    toSend: function(t) {
        var e = t.currentTarget.dataset.detail;
        this.setData({
            isSend: !0,
            detail: e
        });
    },
    toChange: function(t) {
        var e = t.currentTarget.dataset.detail;
        this.setData({
            changePrice: !this.data.changePrice,
            price: e.total_goods_price,
            detail: e,
            express: e.express_price,
            total: "￥" + e.total_pay_price
        });
    },
    toAbout: function(t) {
        this.setData({
            about: t.detail.value
        });
    },
    priceInput: function(t) {
        var e = void 0;
        e = t.detail.value > -.01 ? "￥" + (+t.detail.value + +this.data.express).toFixed(2) : "数据有误", 
        this.setData({
            price: t.detail.value,
            total: e
        });
    },
    expressInput: function(t) {
        var e = void 0;
        e = t.detail.value > -.01 ? "￥" + (+t.detail.value + +this.data.price).toFixed(2) : "数据有误", 
        this.setData({
            express: t.detail.value,
            total: e
        });
    },
    onReady: function(t) {
        this.setData({
            page_loading: !1
        });
    },
    onShow: function() {
        this.getList();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});